
// prepare the form when the DOM is ready 
$(document).ready(function() { 
    var options = { 
        target:        '#output',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse,  // post-submit callback 
        
        dataType:  'json' 
    }; 
 
    
    // bind to the form's submit event 
    $('form.frmAjax').live('submit',function() { 
        $(this).ajaxSubmit(options); 
 
        return false; 
    })

}); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    jQuery('#wrapper').block();
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText, xhr, $form)  {
    jQuery('#wrapper').unblock();
    if(responseText.error) alert(responseText.error);
    if(responseText.msg) jQuery('#output').html(responseText.msg).slideUp(300).delay(800).fadeIn(400);
    if(responseText.load) jQuery('#content_main').load(responseText.load);
} 

